<?php



// action links ----------------------------------------------------------------

/**
 * Edition link
 * @param ressource: object to be edited
 * @param target: url to invoke on object
 * @return anchor tag
 */
function edit_link($ressource, $target)
{
	return anchor('admin/'.$target.'/'.$ressource->id, icon_tag('pencil'), 'title="Modifier cet élément"');
}

/**
 * Delete link, with in place confirmation using jquery-confirm
 * @param ressource: object to be deleted
 * @param js_function: javascript function called on object
 * @return anchor tag
 */
function delete_link($ressource, $js_function)
{
	return '<a href="javascript:'.$js_function.'('.$ressource->id.')" 
	           class="js-confirm"
	           title="Supprimer cet élément">
	           '.icon_tag('cross').'
	        </a>';
}


function details_link($ressource, $js_function)
{
	return '<a href="javascript:'.$js_function.'('.$ressource->id.')" title="Voir cet élément">'.icon_tag('magnifier').'</a>';
}

function js_link($ressource, $js_function, $name, $title="")
{
	return '<a href="javascript:'.$js_function.'('.$ressource->id.')" title="'.$title.'">'.$name.'</a>';
}


function bool_icon($value)
{
	return '<span class="hidden">'.$value.'</span>'.icon_tag($value ? 'accept' : 'exclamation');
}


function include_tinymce()
{
	echo '<script src="'.base_url().'/javascript/tiny_mce/tiny_mce.js" type="text/javascript"></script>';
	echo '<script src="'.base_url().'/javascript/tiny_mce/init.js" type="text/javascript"></script>';
}

